﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace KPIS.GERP.Models.ViewModel
{
    [DataContract]
    public class VMInitialStartLog
    {
        public void Start()
        {
            InitialDateTimeStart = DateTime.Now;
        }

        public void FinishedInitial()
        {
            InitialDateTimeEnd = DateTime.Now;
        }

        private TimeSpan ServerUpTimeSpan
        {
            get { return DateTime.Now.Subtract(InitialDateTimeStart); }
        }

        public string ServerUpTime
        {
            get { return Class.StringFormat.TimeSpan(ServerUpTimeSpan); }
        }

        public string InitialWasteTime
        {
            get
            {
                return InitialDateTimeEnd.HasValue
                           ? Class.StringFormat.TimeSpan(InitialDateTimeEnd.Value.Subtract(InitialDateTimeStart))
                           : "Not complete, spent time for " + ServerUpTime;
            }
        }

        [DataMember]
        public DateTime InitialDateTimeStart { get; set; }

        [DataMember]
        public DateTime? InitialDateTimeEnd { get; set; }

    }
}